<template>
	<view>
		<view class="staff">
			<view class="staff-em"></view>
			<view class="staff-text">活动列表</view>
		</view>

		<scroll-view scroll-y :style="'height:'+scrollH+'px;'">
			<view v-if="activity_list_data" class="line-h-md">
				<block v-for="(item,index) in activity_info" :key="index">
					<view class="ml-5 mr-5 mt-2">
						<view class="contenttext">活动名称：{{item.title}}({{fac_name}})</view>
						<view class="contenttext">活动内容：{{item.content}}</view>
					</view>

					<view class="link">
						<view @click="details(index)">进入详情页 >></view>
						<view @click="mange(index)">进入管理页 >></view>
					</view>

					<divider />
				</block>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props: {
			activity_list_data: null,
			scrollH: null,
			activity_info: null,
			fac_name: null,
		},
		methods: {
			//打开详情页面
			details(index) {
				uni.navigateTo({
					url: '../index/index?activity_id=' + 
						this.activity_list_data[index].fac_info.activity_id + 
						'&factory_id=' +
						this.activity_list_data[index].fac_info.id + 
						'&staff_id=' + 
						this.activity_list_data[index].id,
				})
			},
			
			//先获取审核状态，打开管理页面
			mange(index) {
				this.$comm.request({
					url: 'api/staff_status',
					method: 'GET',
					data: {
						fac_id: this.activity_list_data[index].fac_info.id,
					},
					success: res => {
						var res = res.data
						console.log(res)
						console.log(res.code + res.msg)
						if (res.code == 201) {
							uni.navigateTo({
								url: './staff_sign?factory_id=' + 
								this.activity_list_data[index].fac_info.id + 
								'&activity_id=' + 
								this.activity_list_data[index].fac_info.activity_id
							})
						} else {
							uni.navigateTo({
								url: 'invitation?factory_id=' + 
								this.activity_list_data[index].fac_info.id + 
								'&activity_id=' + 
								this.activity_list_data[index].fac_info.activity_id
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	@import '@/common/main.css';
	@import  '@/common/zcm-main.css';
	
	.staff {
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 50rpx;
		margin-top: 30rpx;
	
		.staff-em {
			height: 35rpx;
			width: 10rpx;
			background-color: #475dfc;
			border-radius: 50rpx;
		}
	
		.staff-text {
			font-weight: bold;
			margin-left: 10rpx;
		}
	}
	
	.contenttext {
		overflow: hidden;
		/* break-all(允许在单词内换行。) */
		word-break: break-all;
		/* 超出部分省略号 */
		text-overflow: ellipsis;
		/** 对象作为伸缩盒子模型显示 **/
		display: -webkit-box;
		/** 设置或检索伸缩盒对象的子元素的排列方式 **/
		-webkit-box-orient: vertical;
		/** 显示的行数 **/
		-webkit-line-clamp: 1;
	}
	
	.link {
		display: flex;
		padding: 0 50rpx 0 50rpx;
		text-align: center;
	
		view {
			color: #475dfc;
			width: 50%;
		}
	
		.link-text {
			width: 5rpx;
			border-radius: 5rpx;
			background-color: #D9D9D9;
		}
	}
	
</style>
